<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="/assets/awesome/css/main.css">
    <link type="text/css" href="/assets/awesome/css/font-awesome.min.css" rel="stylesheet">
    <title>Login - 管理平台登录</title>
  </head>

  <body>
    <section class="material-half-bg">
      <div class="cover"></div>
    </section>
    <section class="login-content">
      <div class="logo">
        <h1>Zero - Art</h1>
      </div>
      <div class="login-box">
        <form class="login-form" id="admin-login">
          <h3 class="login-head"><i class="fa fa-lg fa-fw fa-user"></i>管理员</h3>
          <div class="form-group">
            <label class="control-label">账号</label>
            <input class="form-control" type="text" name="username" value="" placeholder="请输入账号" autofocus>
          </div>
          <div class="form-group">
            <label class="control-label">密码</label>
            <input class="form-control" type="password" name="password" placeholder="请输入密码">
          </div>
          <div class="form-group">
            <div class="utility">
              <div class="animated-checkbox">
                <label>
                  <input type="checkbox">
                  <span class="label-text">记住密码</span> </label>
              </div>
              <p class="semibold-text mb-2"><a href="#" data-toggle="flip"></a></p>
            </div>
          </div>
          <div class="form-group btn-container">
            <button type="button" class="btn btn-primary btn-block"><i class="fa fa-sign-in fa-lg fa-fw"></i>登录</button>
          </div><span style="color:#e60c0c"></span>
        </form>
      </div>
    </section>
    <!-- Essential javascripts for application to work-->
    <script src="/assets/other/js/jquery.min.js"></script>
    <!-- The javascript plugin to display page loading on top-->
    <script src="/assets/awesome/js/plugins/pace.min.js"></script>
    <script src="/assets/layui/layui.all.js"></script>
    <script type="text/javascript">
      // Login Page Flipbox control
      $('.login-content [data-toggle="flip"]').click(function () {
        $('.login-box').toggleClass('flipped');
        return false;
      });
      //回车提交事件
      $("body").keydown(function () {
        if (event.keyCode == "13") {//keyCode=13是回车键
          $('#admin-login button').click();
        }
      });
      $('#admin-login button').click(function () {
        fd = new FormData(document.getElementById('admin-login'));
        $.ajax({
          url: '/admin/login',
          type: "POST",
          timeout: "5000",
          dataType: "json",
          contentType: 'application/x-www-form-urlencoded;charset=utf-8',
          data: fd,
          contentType: false,
          processData: false,
          success: function (data) {
            if (data.code == "200") {
              layer.msg(data.msg, { time: 1000 }, function () {
                window.location.href = "/<?php echo ADMIN_PATH;?>";
              });
            } else {
              layer.msg(data.msg);
            }
          },
          error: function (XMLResponse) {
            layer.msg(XMLResponse.error);
          }
        });
      });
    </script>
  </body>

</html>